/*============================================================================*/
/*                   CONTINENTAL AUTOMOTIVE SYSTEMS                           */
/*============================================================================*/
/*                        OBJECT SPECIFICATION                                */
/*============================================================================*
* name:            HWInit.c
* version:         1.1
* created_by:      Rodrigo Casados
* date_created:    June 7 2013
*=============================================================================*/
/* DESCRIPTION : Source file to implement main function.                      */
/*============================================================================*/
/* FUNCTION COMMENT : Implements entry point (main function) and other        */
/* application stuff.                                                         */
/*                                                                            */
/*============================================================================*/
/*                               OBJECT HISTORY                               */
/*============================================================================*/
/*  REVISION |   DATE      |                               |      AUTHOR      */
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*  1.1      | 7/June/2013 |                               | Rodrigo Casados */
/* Initial version for the Smart Car Race 2010 contest using Freescale        */
/* Bolero micro.                                                              */
/*============================================================================*/
#include "APPControl.h"


void WIPERS(void)
{
	static uint16_t Btn=0;
	Btn=fv_Checkbtn();
			switch(Btn)
			{
				case BTN1:
				{
					SM_BTN(BTN1_STATE);
					break;
				}
				
				case BTN2:
				{
					SM_BTN(BTN2_STATE);
					break;
				}
				
				case BTN3:
				{
					SM_BTN(BTN3_STATE);
					break;
				}
				
				case BTN4:
				{
					SM_BTN(BTN4_STATE);
					break;
				}
				default:
					OFF_LED();
					break;
			}
	  	
}


void SM_BTN(E_SM_BTN e_sm_btn)
{
	switch(e_sm_btn)
	{
		case BTN1_STATE:
		{
			/*AQUI VA EL MODO OFF*/
			OFF_LED();
			SM_WIPER(WIPER_POSITION_OFF);
			break;
		}
		case BTN2_STATE:
		{
			/*AQUI VA EL MODO SLOW*/
			SLOW_LED();
			SM_WIPER(WIPER_POSITION_SLOW);
			break;
		}
		case BTN3_STATE:
		{
			/*AQUI VA EL MODO FAST*/
			FAST_LED();
			SM_WIPER(WIPER_POSITION_FAST);
			break;
		}
		case BTN4_STATE:
		{
			/*AQUI VA EL MODO AUTO*/
			AUTO_LED();
			Wiper_AutoPos();
			break;
		}
		default:
			break;
	}
}

/*****************************************************************/

void Ligths(void)
{
	static uint16_t Btn=0;
	Btn=fv_Checkbtn();
			switch(Btn)
			{
				case BTN1:
				{
					SM_BTN2(BTN1_STATE);
					break;
				}
				
				case BTN2:
				{
					SM_BTN2(BTN2_STATE);
					break;
				}
				
				case BTN3:
				{
					SM_BTN2(BTN3_STATE);
					break;
				}
				
				case BTN4:
				{
					SM_BTN2(BTN4_STATE);
					break;
				}
				default:
					LigthsOff_LED();
					break;
			}
	  	
}


void SM_BTN2(E_SM_BTN e_sm_btn)
{
	switch(e_sm_btn)
	{
		case BTN1_STATE:
		{
			/*AQUI VA EL MODO OFF*/
			LigthsOff();
			LigthsOff_LED();
			break;
		}
		case BTN2_STATE:
		{
			/*AQUI VA EL MODO  PARKLAMPS*/
			Parklamps();
			Parklamps_LED();
			break;
		}
		case BTN3_STATE:
		{
			/*AQUI VA EL MODO HEADLAMPS*/
			Headlamps();
			Headlamps_LED();
			break;
		}
		case BTN4_STATE:
		{
			/*AQUI VA EL MODO AUTO*/
			 Auto_Ligths();
			Auto_LED();
			break;
		}
		default:
			break;
	}
}